<?php
namespace app\common\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule =   [
        'id'               => 'require|number',
        'staff_no|工号'    => 'require|length:8',
        'mobile|手机号'    => 'require|mobile',
        'code|验证码'      => 'require|length:4',
        'name|昵称'        => 'require|length:1,50',
        'avatars|头像'     => 'require',
        'openid'           => 'require',
        'session_key'      => 'require',
        'encrypted_data'   => 'require',
        'iv'               => 'require',
        'password|密码'    => 'require|length:5,20',
        'section_id|部门'  => 'require',
    ];
    
    protected $scene = [
        /** api */
        'wxlogin' => ['name', 'avatars', 'openid'],
        'decrypt' => ['session_key', 'encrypted_data', 'iv'],

        /** admin */
        'admin_login'   => ['staff_no', 'password'],
        'edit_password' => ['staff_no', 'password'],
        'edit'          => ['id', 'name', 'section_id', 'check_clock_id', 'subsidy', 'rule_salary_id', 'card_num', 'status'],
    ];
}